﻿using System.Runtime.CompilerServices;
using Autofac;

namespace DayDayUp.Core
{

    public class EngineContext
    {
    
        [MethodImpl(MethodImplOptions.Synchronized)]
        public static IEngine Initialize(bool forceRecreate,IContainer container)
        {
            if (Singleton<IEngine>.Instance == null || forceRecreate)
            {
                Singleton<IEngine>.Instance = CreateEngineInstance();
                Singleton<IEngine>.Instance.Initialize(container);
            }
            return Singleton<IEngine>.Instance;
        }

       
        public static void Replace(IEngine engine)
        {
            Singleton<IEngine>.Instance = engine;
        }
        
     
        public static IEngine CreateEngineInstance()
        {
            return new DmsEngine();
        }

       

        public static IEngine Current
        {
            get
            {
              
                return Singleton<IEngine>.Instance;
            }
        }
    }
}
